package com.subang.function.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.subang.common.annotation.Log;
import com.subang.common.core.controller.BaseController;
import com.subang.common.core.domain.AjaxResult;
import com.subang.common.enums.BusinessType;
import com.subang.function.domain.SbWoodenFishHits;
import com.subang.function.service.ISbWoodenFishHitsService;
import com.subang.common.utils.poi.ExcelUtil;
import com.subang.common.core.page.TableDataInfo;

/**
 * 祈福Controller
 * 
 * @author subei
 * @date 2025-04-30
 */
@RestController
@RequestMapping("/function/hits")
public class SbWoodenFishHitsController extends BaseController
{
    @Autowired
    private ISbWoodenFishHitsService sbWoodenFishHitsService;

    /**
     * 查询祈福列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SbWoodenFishHits sbWoodenFishHits)
    {
        startPage();
        List<SbWoodenFishHits> list = sbWoodenFishHitsService.selectSbWoodenFishHitsList(sbWoodenFishHits);
        return getDataTable(list);
    }

    /**
     * 导出祈福列表
     */
    @PreAuthorize("@ss.hasPermi('function:hits:export')")
    @Log(title = "祈福", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SbWoodenFishHits sbWoodenFishHits)
    {
        List<SbWoodenFishHits> list = sbWoodenFishHitsService.selectSbWoodenFishHitsList(sbWoodenFishHits);
        ExcelUtil<SbWoodenFishHits> util = new ExcelUtil<SbWoodenFishHits>(SbWoodenFishHits.class);
        util.exportExcel(response, list, "祈福数据");
    }

    /**
     * 获取祈福详细信息
     */
    @PreAuthorize("@ss.hasPermi('function:hits:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(sbWoodenFishHitsService.selectSbWoodenFishHitsByRecordId(recordId));
    }

    /**
     * 新增祈福
     */
    @Log(title = "祈福", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SbWoodenFishHits sbWoodenFishHits)
    {
        int result = sbWoodenFishHitsService.insertSbWoodenFishHits(sbWoodenFishHits);
        if (result > 0) {
            List<SbWoodenFishHits> list = sbWoodenFishHitsService.selectSbWoodenFishHitsList(sbWoodenFishHits);
            return success(list);
        }
        return toAjax(result);
    }

    /**
     * 修改祈福
     */
    @Log(title = "祈福", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SbWoodenFishHits sbWoodenFishHits)
    {
        return toAjax(sbWoodenFishHitsService.updateSbWoodenFishHits(sbWoodenFishHits));
    }

    /**
     * 删除祈福
     */
    @PreAuthorize("@ss.hasPermi('function:hits:remove')")
    @Log(title = "祈福", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(sbWoodenFishHitsService.deleteSbWoodenFishHitsByRecordIds(recordIds));
    }
}
